<?php

function register_product_taxonomy() {

    $name = '产品分类';
    $slug = 'product_cat';

    $arr = array(
        'name' => $name,
        'singular_name' => $name,
        'search_items' => sprintf(__('搜索%s', 'b2'), $name),
        'all_items' => sprintf(__('所有%s', 'b2'), $name),
        'parent_item' => sprintf(__('父级%s', 'b2'), $name),
        'parent_item_colon' => sprintf(__('父级%s', 'b2'), $name),
        'edit_item' => sprintf(__('编辑%s', 'b2'), $name),
        'update_item' => sprintf(__('更新%s', 'b2'), $name),
        'add_new_item' => sprintf(__('添加%s', 'b2'), $name),
        'new_item_name' => sprintf(__('%s名称', 'b2'), $name),
        'menu_name' => $name,
    );

    $args = array(
        'hierarchical' => true,
        'labels' => $arr,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'show_in_rest' => true,
        'rewrite' => array('slug' => $slug, 'with_front' => false),
    );

    register_taxonomy('product_cat', array('producthunt'), $args);

}

add_action('init', 'register_product_taxonomy');